/*
 * syscfg.c
 *
 *  Created on: 2021-12-09
 *      Author: chenss
 */

#include "syscfg.h"
#include "NuPin/PinConfig.h"
#include "serial.h"

#define UART_CFG(n, rate) { \
    PinConfig_init_uart##n(); \
    UART_Open(UART##n, rate); \
    Main_SetPriority(UART##n##_IRQn, 3, 0); \
    NVIC_EnableIRQ(UART##n##_IRQn); \
}

void SysCfg_Uart0(void)
{
    UART_CFG(0, 115200);
}

void SysCfg_Uart2(void)
{
    UART_CFG(2, 115200);
}

void UART0_IRQHandler(void)
{
    Serial_IRQHandler(Serial_0);
}

void UART2_IRQHandler(void)
{
    Serial_IRQHandler(Serial_2);
}
